from conans import ConanFile, CMake, tools  
import os  
  
class HelloConan(ConanFile):  
    name = "hello"  
    version = "1.0"  
    license = "MIT"  
    author = "Your Name"  
    url = "https://github.com/yourname/hello"  
    description = "Conan package for the Hello library"  
    topics = ("hello", "world", "example")  
    settings = "os", "compiler", "build_type", "arch"  
    options = {"shared": [True, False], "fPIC": [True, False]}  
    default_options = {"shared": False, "fPIC": True}  
    generators = "cmake", "cmake_find_package"  

    def requirements(self):
        self.requires("protobuf/3.19.1")
        
    def source(self):  
        self.run("git clone https://github.com/yourname/hello.git")  
        # 假设源代码在 hello/ 目录下  
        os.chdir("hello")  
        self.run("git checkout origin/master")  
  
    def build(self):  
        cmake = CMake(self)  
        cmake.configure(source_dir=".", build_dir="./")  
        cmake.build()  
  
    def package(self):  
        self.copy("*.h", dst="include", src="include")  
        self.copy("*hello.lib", dst="lib", keep_path=False)  
        self.copy("*.dll", dst="bin", keep_path=False)  
        self.copy("*.so", dst="lib", keep_path=False)  
        self.copy("*.a", dst="lib", keep_path=False)  
  
    def package_info(self):  
        self.cpp_info.libs = ["hello"]